<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>FSF.MkTemp</title>
<meta http-equiv="Content-Type" Content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="../../styles/styles.css">
<script language="javascript" src='../links.js' type="text/javascript"></script>
</head>
<body>

<h1>MkTemp</h1>
<div class=navbar>
<a href="../index.html">main</a> |
<a href="index.html">FarStandardFunctions</a>
</div>

<div class=shortdescr>
The <dfn>FSF.MkTemp</dfn> function is used to create a temporary
file name with the path based on a specified template.
</div>

<pre class=syntax>
char* WINAPI MkTemp(
  char *Dest,
  const char *Prefix
);
</pre>

<h3>Parameters</h3>
<div class=descr>
  <div class=dfn>Dest</div>
  <div class=dfndescr>Pointer to buffer to receive the temporary file name.
    It must be large enough to hold the resulting string (the path to
    the temporary directory + 12 characters for the name of the
    temporary file).
  </div>

  <div class=dfn>Prefix</div>
  <div class=dfndescr>
    Points to a null-terminated prefix string. At most four leading
    characters from that string will be used as the filename prefix.
    FAR will pad the prefix with zeroes if its length is less than
    4 bytes.<br>
    If <var>Prefix</var> is <code>NULL</code> or points to an empty string,
    the standard prefix <code>"FTMP"</code> will be used.
  </div>
</div>

<h3>Return value</h3>
<div class=descr>
Pointer to <em>Dest</em> containing the temporary file name, or NULL if function
has failed. A possible reason for the failure is that the temporary directory
contains too many files and should be cleaned.
</div>

<h3>Remarks</h3>
<div class=descr>
<ol>
<li>The temporary file name is obtained by concatenating the temporary
directory path (returned by the <a href="win32/GetTempPath">GetTempPath</a>
Windows API function), the prefix passed to the function and several random hexadecimal digits.
The name has the following format:<p>
<code>PrefXXXP.PTT</code><p>

where<br>
&nbsp;&nbsp;&nbsp;<b>Pref</b> - Pref is the 4-character prefix;<br>
&nbsp;&nbsp;&nbsp;<b>XXX</b> - three random hexadecimal digits;<br>
&nbsp;&nbsp;&nbsp;<b>PP</b> - two hexagemical digits from process ID (returned by the
<a href="win32/GetCurrentProcessId">GetCurrentProcessId</a> Windows API function);<br>
&nbsp;&nbsp;&nbsp;<b>TT</b> - two hexagemical digits from thread ID (returned by the
<a href="win32/GetCurrentThreadId">GetCurrentThreadId</a> Windows API function).<br>

<li>Unlike in FAR 1.70 beta 3, this function does not
create the file on the disk; it only generates the name.

<li>In FAR 1.70 beta 3, this function used only the
first three characters of the prefix.

</ol>
</div>

<h3>Example</h3>
<div class=descr>
<pre class=code>
char TempName[NM];

FSF.MkTemp(TempName,NULL);        -&gt; "FTMP000D.P50"
FSF.MkTemp(TempName,"");          -&gt; "FTMP000D.P50"
FSF.MkTemp(TempName,"MY");        -&gt; "MY00000D.P50"
FSF.MkTemp(TempName,"BaR");       -&gt; "BAR0000D.P50"
FSF.MkTemp(TempName,"TstPlugin"); -&gt; "TSTP000D.P50"
</pre>
</div>

</body>
</html>
